#include <bits/stdc++.h>

#define in read()
#define fi first
#define se second
#define pb push_back
#define rep(i, x, y) for(int i = (x); i <= (y); i++)
#define per(i, x, y) for(int i = (x); i >= (y); i--)

using namespace std;

typedef long long ll;
typedef double db;
typedef vector < int > vec;
typedef pair < int , int > pii;

int read() {
    int x = 0; bool f = 0; char ch = getchar(); while(!isdigit(ch)) f |= ch == '-',ch = getchar();
    while(isdigit(ch)) x = x * 10 + (ch ^ 48),ch = getchar(); return f ? -x : x;
}

ll pw[35], mx[35], stk[35], ans, v[35];
int cnt, D;

ll dfs(int x, ll res) {
	if(x == cnt + 1) {
		if(res == 0) {
//			rep(i, 1, cnt) cerr << v[i] << " " ;
//			cerr << endl;
			return 1;
		} return 0;
	}
	if(res > mx[x] || res < -mx[x]) return 0;
	ll t = 0;
	rep(i, 0, 9) {
		int cho = 10 - i; if(x == 1) cho --; 
		v[x] = -i;
		if(cho > 0) t += dfs(x + 1, res - stk[x] * i) * cho;
		cho = 10 - i;
		if(i == 0) continue; v[x] = i;
		if(cho > 0) t += dfs(x + 1, res + stk[x] * i) * cho;
	} return t;
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("1.in","r",stdin);
#endif
    D = in;
	pw[0] = 1; rep(i, 1, 33) pw[i] = pw[i - 1] * 10;
	rep(i, 1, 17) {
		int l = 0, r = i; cnt = 0;
		while(l < r) {
			stk[++cnt] = pw[r] - pw[l];
			r--; l++;
		} //rep(j, 1, cnt) cerr << stk[j] << " "; cerr << endl;
		mx[cnt + 1] = 0;
		per(j, cnt, 1) mx[j] = mx[j + 1] + stk[j] * 9;
		ans += dfs(1, D) * (i & 1 ? 1 : 10);// cerr << ans << endl;
	}
	cout << ans << endl;
}
